﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Windows.Data;
namespace Design.ViewModel
{
    public class MainViewModel:ViewModelBase
    {
        public ICommand buttonclick {get;set;}
        public List<dulieu> newdl { get; set; }
        public List<dataCb> cbdl { get; set; }
        public PagedCollectionView collection { get; set; }
        public ICommand CommandDataGrid { get; set; }
        public int Sumitem ;
        public int sumitem
        {
            get { return this.Sumitem; }
            set { this.Sumitem = value; OnPropertyChanged("sumitem"); }
        }
        public MainViewModel()
        {
            Is_expand = false;
            this.Sumitem = 5;
            buttonclick = new DelegateCommand<object>(Buttonpress);

            cbdl = new List<dataCb>()
            {
                new dataCb(){value=5},
                new dataCb(){value=10},
                new dataCb(){value=15}
            };
            
            newdl = new List<dulieu>()
            {
                new dulieu(){Id="1",Name="Thanh Minh"},
                new dulieu(){Id="2",Name=" Van Tan"},
                new dulieu(){Id="3",Name="Tan Toan"},
                new dulieu(){Id="4",Name="Bao Ngoc"},
                new dulieu(){Id="5",Name="Bao Ngoc"},
                new dulieu(){Id="6",Name="Bao Ngoc"},
                new dulieu(){Id="7",Name="Bao Ngoc"},
                new dulieu(){Id="8",Name="Bao Ngoc"},
                new dulieu(){Id="9",Name="Bao Ngoc"},
                new dulieu(){Id="10",Name="Tan Toan"},
                new dulieu(){Id="11",Name="Tan Toan"},
                new dulieu(){Id="12",Name="Tan Toan"},
                new dulieu(){Id="13",Name="Tan Toan"},
                new dulieu(){Id="14",Name="Tan Toan"},
                new dulieu(){Id="15",Name="Tan Toan"},
                new dulieu(){Id="16",Name="Tan Toan"},
                new dulieu(){Id="17",Name="Tan Toan"},
                new dulieu(){Id="18",Name="Tan Toan"},
                new dulieu(){Id="19",Name="Tan Toan"},
                new dulieu(){Id="20",Name="Tan Toan"},

                new dulieu(){Id="21",Name="Bao Ngoc"}

            };
            OnPropertyChanged("newdl");
            collection = new PagedCollectionView(newdl);
            CommandDataGrid = new DelegateCommand<object>(CommandDG);
        }

        private void CommandDG(object obj)
        {
            if (obj.ToString() == "AddRow")
            {

                collection.MoveToLastPage();
                collection.AddNew();
                collection.CommitNew();
                
                
            }

        }
        private bool is_expand;
        public bool Is_expand
        {
            get { return this.is_expand; }
            set
            {
                this.is_expand = value; OnPropertyChanged("Is_expand");
               
            }
        }
        public void Buttonpress(object notUsed)
        {
            Is_expand = true;
            
            var window = new ChildWindow2();
            window.Title = "DynamicPage";
            window.Show();
        }
        
    }
    public class dulieu
    {
        public string Id { get; set; }
       public string Name { get; set; }
    }
    public class dataCb
    {
       
        public int value { get; set; }
    }
}
